package com.teng.mylibrary.util

import com.tencent.mmkv.MMKV
import com.teng.mylibrary.Constants

/**
 * Description:    配置清单
 * Author:         liuteng
 * CreateDate:     2021年12月3日
 * UpdateRemark:   更新说明
 */
object SPUtil {

    private const val IP = "ip"
    private const val IP_LIST = "iplist"
    private const val CONNECT_OUT_TIME = "connectouttime" //连接超时时间
    private const val DOEXIT_TIME = "doexittime"  //无操作退出时间
    private const val DOEXIT = "doexit" //是否无操作退出
    private const val ACCOUNT = "account"
    private const val PASSWORD = "password"
    private const val KINGDEEPASSWORD = "kingdeepassword"
    private const val KINGDEEUSERNAME = "kingdeeusername"
    private const val USERID = "userId"
    private const val USERNAME = "username"
    private const val ORGANIZATION_ID = "organizationId"
    private const val REMEMBER = "remember" //记住密码


    fun getIp(): String {
        return MMKV.defaultMMKV().getString(IP, Constants.IP_ADDRESS)!!
    }

    fun setIp(ip: String) {
        MMKV.defaultMMKV().putString(IP, ip)
    }

    fun getIpList(): String {
        return MMKV.defaultMMKV().getString(IP_LIST, "")!!
    }

    fun setIpList(ipList: String) {
        MMKV.defaultMMKV().putString(IP_LIST, ipList)
    }

    fun getConnectTimeOut(): String {
        return MMKV.defaultMMKV().getString(CONNECT_OUT_TIME, Constants.CONNECT_TIME_OUT)!!
    }

    fun setConnectTimeOut(time: String) {
        MMKV.defaultMMKV().putString(CONNECT_OUT_TIME, time)
    }

    fun getDoExitTime(): String {
        return MMKV.defaultMMKV().getString(DOEXIT_TIME, "0")!!
    }

    fun setDoExitTime(time: String) {
        MMKV.defaultMMKV().putString(DOEXIT_TIME, time)
    }

    fun getAccount(): String {
        return MMKV.defaultMMKV().getString(ACCOUNT, "")!!
    }

    fun setAccount(account: String) {
        MMKV.defaultMMKV().putString(ACCOUNT, account)
    }

    fun getPassword(): String {
        return MMKV.defaultMMKV().getString(PASSWORD, "")!!
    }

    fun setPassword(password: String) {
        MMKV.defaultMMKV().putString(PASSWORD, password)
    }

    fun getKingDeePassword(): String {
        return MMKV.defaultMMKV().getString(KINGDEEPASSWORD, "")!!
    }

    fun setKingDeePassword(password: String) {
        MMKV.defaultMMKV().putString(KINGDEEPASSWORD, password)
    }

    fun getKingDeeUserName(): String {
        return MMKV.defaultMMKV().getString(KINGDEEUSERNAME, "")!!
    }

    fun setKingDeeUserName(username: String) {
        MMKV.defaultMMKV().putString(KINGDEEUSERNAME, username)
    }

    fun setUserId(userId: String) {
        MMKV.defaultMMKV().putString(USERID, userId)
    }

    fun getUserId(): String {
        return MMKV.defaultMMKV().getString(USERID, "")!!
    }

    fun setUsername(username: String) {
        MMKV.defaultMMKV().putString(USERNAME, username)
    }

    fun getUsername(): String {
        return MMKV.defaultMMKV().getString(USERNAME, "")!!
    }

    fun getOrganizationId(): String {
        return MMKV.defaultMMKV().getString(ORGANIZATION_ID, "")!!
    }

    fun setOrganizationId(organizationId: String) {
        MMKV.defaultMMKV().putString(ORGANIZATION_ID, organizationId)
    }

    fun isRemember(): Boolean {
        return MMKV.defaultMMKV().getBoolean(REMEMBER, false)
    }

    fun setRemember(remember: Boolean) {
        MMKV.defaultMMKV().putBoolean(REMEMBER, remember)
    }

    fun isDoExit(): Boolean {
        return MMKV.defaultMMKV().getBoolean(DOEXIT, false)
    }

    fun setDoExit(doExit: Boolean) {
        MMKV.defaultMMKV().putBoolean(DOEXIT, doExit)
    }
}